home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / infosrvr / dev / scott / WWW / NextStep / Implementation / old / HTUtils.h < prev    next >
C/C++ Source or Header  |  1992-11-24  |  6KB  |  223 lines

  1. /*    Macros for general use                    HTUtils.h
  2. **
  3. **    See also: the system dependent file "tcp.h"
  4. */
  5.  
  6. /* extern void *malloc(size_t size); */
  7.  
  8. #ifndef HTUTILS_H
  9. #define HTUTILS_H
  10.  
  11. #define DEBUG        /* Turn on trace output when WWW_TraceFlag set */
  12.  
  13. #ifdef SHORT_NAMES
  14. #define WWW_TraceFlag HTTrFlag
  15. #endif
  16.  
  17. /*    Debug message control.
  18. */
  19. #ifdef DEBUG
  20.     
  21. #ifndef STDIO_H
  22. #include <stdio.h>
  23. #define STDIO_H
  24. #endif
  25.     
  26. #define TRACE (WWW_TraceFlag)
  27. #define PROGRESS(str) printf(str)
  28.     extern int WWW_TraceFlag;
  29. #else
  30. #define TRACE 0
  31. #define PROGRESS(str) /* nothing for now */
  32. #endif
  33.  
  34. #define CTRACE if(TRACE)fprintf
  35. #define tfp stdout
  36.  
  37.  
  38. /*    Standard C library for malloc() etc
  39. */
  40. #ifdef vax
  41. #ifdef unix
  42. #define ultrix    /* Assume vax+unix=ultrix */
  43. #endif
  44. #endif
  45.  
  46. #ifndef VMS
  47. #ifndef ultrix
  48. #ifdef NeXT
  49. #include <libc.h>    /* NeXT */
  50. #endif
  51. #ifndef MACH /* Vincent.Cate@furmint.nectar.cs.cmu.edu */
  52. #include <stdlib.h>    /* ANSI */
  53. #endif
  54. #else /* ultrix */
  55. #include <malloc.h>
  56. #include <memory.h>
  57. #include <stdio.h>
  58. #endif
  59.  
  60. #else    /* VMS */
  61. #include <stdio.h>
  62. #include <ctype.h>
  63. #endif
  64.  
  65. #define PUBLIC            /* Accessible outside this module     */
  66. #define PRIVATE static        /* Accessible only within this module */
  67.  
  68. #ifdef __STDC__
  69. #define CONST const        /* "const" only exists in STDC */
  70. #define NOPARAMS (void)
  71. #define PARAMS(parameter_list) parameter_list
  72. #define NOARGS (void)
  73. #define ARGS1(t,a) \
  74.         (t a)
  75. #define ARGS2(t,a,u,b) \
  76.         (t a, u b)
  77. #define ARGS3(t,a,u,b,v,c) \
  78.         (t a, u b, v c)
  79. #define ARGS4(t,a,u,b,v,c,w,d) \
  80.         (t a, u b, v c, w d)
  81. #define ARGS5(t,a,u,b,v,c,w,d,x,e) \
  82.         (t a, u b, v c, w d, x e)
  83. #define ARGS6(t,a,u,b,v,c,w,d,x,e,y,f) \
  84.         (t a, u b, v c, w d, x e, y f)
  85. #define ARGS7(t,a,u,b,v,c,w,d,x,e,y,f,z,g) \
  86.         (t a, u b, v c, w d, x e, y f, z g)
  87. #define ARGS8(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h) \
  88.         (t a, u b, v c, w d, x e, y f, z g, s h)
  89. #define ARGS9(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i) \
  90.         (t a, u b, v c, w d, x e, y f, z g, s h, r i)
  91. #define ARGS10(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i,q,j) \
  92.         (t a, u b, v c, w d, x e, y f, z g, s h, r i, q j)
  93.  
  94. #else  /* not ANSI */
  95.  
  96. #define CONST
  97. #define NOPARAMS ()
  98. #define PARAMS(parameter_list) ()
  99. #define NOARGS ()
  100. #define ARGS1(t,a) (a) \
  101.         t a;
  102. #define ARGS2(t,a,u,b) (a,b) \
  103.         t a; u b;
  104. #define ARGS3(t,a,u,b,v,c) (a,b,c) \
  105.         t a; u b; v c;
  106. #define ARGS4(t,a,u,b,v,c,w,d) (a,b,c,d) \
  107.         t a; u b; v c; w d;
  108. #define ARGS5(t,a,u,b,v,c,w,d,x,e) (a,b,c,d,e) \
  109.         t a; u b; v c; w d; x e;
  110. #define ARGS6(t,a,u,b,v,c,w,d,x,e,y,f) (a,b,c,d,e,f) \
  111.         t a; u b; v c; w d; x e; y f;
  112. #define ARGS7(t,a,u,b,v,c,w,d,x,e,y,f,z,g) (a,b,c,d,e,f,g) \
  113.         t a; u b; v c; w d; x e; y f; z g;
  114. #define ARGS8(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h) (a,b,c,d,e,f,g,h) \
  115.         t a; u b; v c; w d; x e; y f; z g; s h;
  116. #define ARGS9(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i) (a,b,c,d,e,f,g,h,i) \
  117.         t a; u b; v c; w d; x e; y f; z g; s h; r i;
  118. #define ARGS10(t,a,u,b,v,c,w,d,x,e,y,f,z,g,s,h,r,i,q,j) (a,b,c,d,e,f,g,h,i,j) \
  119.         t a; u b; v c; w d; x e; y f; z g; s h; r i q j;
  120.         
  121.     
  122. #endif /* __STDC__ (ANSI) */
  123.  
  124. #ifndef NULL
  125. #define NULL ((void *)0)
  126. #endif
  127.  
  128.  
  129. /* Note: GOOD and BAD are already defined (differently) on RS6000 aix */
  130. /* #define GOOD(status) ((status)&1)     VMS style status: test bit 0          */
  131. /* #define BAD(status)  (!GOOD(status))     Bit 0 set if OK, otherwise clear   */
  132.  
  133. #ifndef BOOLEAN_DEFINED
  134.     typedef char    BOOLEAN;        /* Logical value */
  135. #ifndef CURSES
  136. #ifndef TRUE
  137. #define TRUE    (BOOLEAN)1
  138. #define    FALSE    (BOOLEAN)0
  139. #endif
  140. #endif
  141. #define BOOLEAN_DEFINED
  142. #endif
  143.  
  144. #ifndef BOOL
  145. #define BOOL BOOLEAN
  146. #endif
  147. #ifndef YES
  148. #define YES (BOOLEAN)1
  149. #define NO (BOOLEAN)0
  150. #endif
  151.  
  152. #ifndef min
  153. #define min(a,b) ((a) <= (b) ? (a) : (b))
  154. #define max(a,b) ((a) >= (b) ? (a) : (b))
  155. #endif
  156.  
  157. #define TCP_PORT 80    /* Allocated to http by Jon Postel/ISI 24-Jan-92 */
  158. #define OLD_TCP_PORT 2784    /* Try the old one if no answer on 80 */
  159. #define DNP_OBJ 80    /* This one doesn't look busy, but we must check */
  160.  
  161. /*    Inline Function WHITE: Is character c white space? */
  162.  
  163. #ifndef NOT_ASCII
  164. #define WHITE(c) (((unsigned char)(c))<=' ')    /* Assumes ASCII but faster */
  165. #else
  166. #define WHITE(c) ( ((c)==' ') || ((c)=='\t') || ((c)=='\n') || ((c)=='\r') )
  167. #endif
  168.  
  169. #define HT_LOADED (29999)        /* Instead of a socket */
  170.  
  171. #include "HTString.h"  /* String utilities */
  172.  
  173. #ifdef __STDC__
  174. #include <stdarg.h>
  175. #else
  176. #include <varargs.h>
  177. #endif
  178.  
  179. #ifdef CURSES
  180.     /* htbrowse.c; */
  181. #include <curses.h>
  182.  
  183.     extern        WINDOW  *w_top, *w_text, *w_prompt;
  184.     extern        void    user_message PARAMS((const char *fmt, ...));
  185.     extern        void    prompt_set PARAMS((CONST char * msg));
  186.     extern        void    prompt_count PARAMS((long kb));
  187. #else
  188. #define user_message printf
  189. #endif
  190.  
  191. /*    Out Of Memory checking for malloc() return:
  192. */
  193. #ifndef __FILE__
  194. #define __FILE__ ""
  195. #define __LINE__ ""
  196. #endif
  197.  
  198. #define outofmem(file, func) \
  199.  { fprintf(stderr, "%s %s: out of memory.\nProgram aborted.\n", file, func); \
  200.   exit(1);}
  201. /* extern void outofmem PARAMS((const char *fname, const char *func)); */
  202.  
  203.  
  204. extern void msg_init PARAMS((int height));
  205. extern void msg_printf PARAMS((int y, const char *fmt, ...));
  206. extern void msg_exit PARAMS((int wait_for_key));
  207.  
  208. /*    Upper- and Lowercase macros
  209. **
  210. **  The problem here is that toupper(x) is not defined officially unless
  211. **  isupper(x) is.  These macros are CERTAINLY needed on
  212. **  #if defined(pyr) || define(mips) or BDSI platforms.
  213. ** For safefy, we make them mandatory.
  214. */
  215. #ifndef TOLOWER
  216.   /* Pyramid and Mips can't uppercase non-alpha */
  217. #define TOLOWER(c) (isupper(c) ? tolower(c) : (c))
  218. #define TOUPPER(c) (islower(c) ? toupper(c) : (c))
  219. #endif /* ndef TOLOWER */
  220.  
  221. #endif /* HTUTILS_H */
  222.  
  223.